|
|
Tom Melly wrote:
>
> Can I guess? (I know practically nothing about C, and absolutely nothing
> about it's internals). Assuming that there is nothing different about the
> output of the calculation, could it be that, when x_ix is an integer value,
> the first example will perform an integer calculation, whereas the second
> example will always perform a floating point calculation?
>
No no no. x_ix and x_jx are floating point numbers in both examples so
both cases require a floating point computation...
> My second guess would be that with the first example the compiler "knows"
> that the result will have no more decimal places than are held by x_ix,
> since 1 is an unequiviqual integer. With the second example, it does not
> view 1.0 as an integer and therefore makes no assumption about the degree of
> precision required in the answer. Am I close? Not even warm? Freezing cold?
> An idiot?
>
Might be... (that this is the explanation, not that you're an idiot :)
> Third guess (and this would imply some idiocy on the part of the compiler).
> When it sees 1.0, it realises that it is an integer and first translates it
> to 1 and then translates it back to a float for the purpose of the
> calculation. With the first example, it is able to skip the first part of
> this process.
>
No, I get similar result if I use a variable instead of the constant
"1" or "1.0" and there is no possible doubt on the type of a variable...
--
* Doctor Jekyll had something * mailto:ber### [at] inamecom
* to Hyde... * http://www.enst.fr/~jberger
*******************************
Post a reply to this message
|
|